<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="Mosaddek">
    <meta name="keyword" content="FlatLab, Dashboard, Bootstrap, Admin, Template, Theme, Responsive, Fluid, Retina">
    <link rel="shortcut icon" href="img/favicon.html">

    <title><%= basicFacts.name %> -- 登录</title>

    <!-- Bootstrap core /css -->
    <link href="/css/bootstrap.min.css" rel="stylesheet">
    <link href="/css/bootstrap-reset.css" rel="stylesheet">
    <!--external /css-->
    <link href="/assets/font-awesome//css/font-awesome.css" rel="stylesheet" />
    <!-- Custom styles for this template -->
    <link href="/css/style.css" rel="stylesheet">
    <link href="/css/style-responsive.css" rel="stylesheet" />

    <!-- HTML5 shim and Respond.js IE8 support of HTML5 tooltipss and media queries -->
    <!--[if lt IE 9]>
    <script src="/js/html5shiv.js"></script>
    <script src="/js/respond.min.js"></script>
    <![endif]-->
    <script src="/js/jquery.js"></script>
</head>

  <body class="login-body">

    <div class="container">

      <form class="form-signin" onsubmit="return login();">
        <h2 class="form-signin-heading"><%= basicFacts.name %>-后台管理程序</h2>
        <div class="login-wrap">
            <input id="userName" type="text" class="form-control" placeholder="用户名" autofocus>
            <input id="password" type="password" class="form-control" placeholder="密码">
            <label class="checkbox">
                <input type="checkbox" value="remember-me"> 自动登录
                <span class="pull-right"> <a href="#">忘记密码?</a></span>
            </label>
            <button class="btn btn-lg btn-login btn-block" type="submit">登录</button>
        </div>
      </form>
    </div>
  <script type="text/javascript">
      var login = function(){

          var n = $('#userName').val();
          var p = $('#password').val();

          if(n === '')
            alert('用户名不准为空');
          else if(p === '')
            alert('密码不准为空');
          else
              $.ajax({
                  url: 'login',
                  type: 'post',
                  data: {n: n, p: p},
                  success: function(data){
                      console.log(data);
                      if(data.status)
                        alert(data.msg);
                      else{
                          window.location.href = 'index';
                      }
                  },
                  error: function(){}
              });

          return false;
      }
  </script>
  </body>
</html>
